/**************************************************************************/
/* Driver for the switches                                                */
/* S1 and S2 switches are connected to Mega16 external interrupts 0 and 1 */
/* S3 is checked by polling.											  */
/**************************************************************************/

#include <avr/io.h>
#include "switch.h"

void SwitchInit()
{
	//Enable switches. PortB.0 output 1
	DDRB |= 0b000000001;
	PORTB |= 0b000000001; 
	//Port D input ( except pin 7)
	DDRD |= 0b00000000;
	// Enable external interrupts 0, 1. (rising edge)
	MCUCR |= 0b00001111;
	GICR |= 0b11000000;
}

uint8_t S3()
{
	if (PINB & 0b00000010) //S3 = PB.1
		return 1;
	else
		return 0;
}
